package com.framework.controller.newcontroller;

import com.framework.entity.or.OrBanner;
import com.framework.exception.util.RespResult;
import com.framework.service.OrLessionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 课程控制类
 * @author wq
 */
@RestController
@RequestMapping("new/lession")
@Api(value="课程模块",tags={"课程模块"})
public class NewLessonController {
    @Autowired
    private OrLessionService orLessionService;


    @GetMapping("/getLessionHeader")
    @ApiImplicitParam(name="token" ,value = "登录所产生的token" ,type = "string" ,required = true,paramType = "query")
    public RespResult getLessionHeader(String token){
         OrBanner banner= orLessionService.getLessonHeader(token);
         return RespResult.ok().put("lession",banner==null?new OrBanner():banner);
    }

    @PostMapping("/getLessionList")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token" ,value = "登录所产生的token" ,type = "string" ,required = true,paramType = "query"),
            @ApiImplicitParam(name="type" ,value = "课程类型 4:首图 5：初级 6:中级" ,type = "string" ,required = true,paramType = "query")
    })
    public RespResult getLessonList(String token,Integer type){
        List<OrBanner> orLessonLists= orLessionService.queryLessonList(token,type);
        return RespResult.ok().put("list",orLessonLists==null || orLessonLists.size()==0?new ArrayList<>():orLessonLists);
    }


}
